import sys

fin =  open("avazu-app.tr","r")
aout = open("app-tr-a.txt","w")
bout = open("app-tr-b.txt","w")

arow = 0
acol = 0
annz = 0
brow = 0
bcol = 1
bnnz = 0

for line in fin:
        #if line_num >100:
        #       break
        tokens = line.split(" ")
        #print tokens
        brow = brow + 1
        if int(tokens[0]) == 1:
                bnnz = bnnz + 1
                bout.write(str(brow) + " 1 "+ tokens[0]+"\n")

        arow = arow + 1
        for token in tokens[1:]:
                arr = token.replace(":"," ").replace("\n","")
                aout.write(str(arow)+" "+arr+"\n")
                brr = arr.split(" ")
                acol = max(acol,int(brr[0]))
                annz = annz + 1
        if brow % 100000 == 0:
                print brow


print "arow=" + str(arow)
print "acol=" + str(acol)
print "annz=" + str(annz)

print "brow=" + str(brow)
print "bcol=" + str(bcol)
print "bnnz=" + str(bnnz)

fin.close()
aout.close()
bout.close()

